import { Info } from '@/api/login'

const state = {
  token: '',
  userinfo: ''

}
const mutations = {
  // 获取token
  SETTOKEN (state, value) {
    console.log(value, 'token')
    state.token = value
  },
  // 修改用户信息
  SETINFO (state, value) {
    state.userinfo = value
  },
  // 删除用户信息
  DELUSER (state) {
    state.token = ''
    state.userinfo = ''
  }
}
const actions = {

  // 获取用户信息
  async setinfo (ctx) {
    const res = await Info()
    console.log(res, '用户信息')
    ctx.commit('SETINFO', res.data)
  }

}
export default {
  // 开启命名空间
  namespaced: true,
  state,
  mutations,
  actions
}
